import { Module } from '@nestjs/common';
import { LogService } from './log.service';
import { LogController } from './log.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { userLog } from '@/modules/log/entities/log.entity';
import * as winston from 'winston';

@Module({
  imports: [TypeOrmModule.forFeature([userLog])],
  controllers: [LogController],
  providers: [
    LogService,
    {
      provide: 'Logger',
      useFactory: () => {
        return winston.createLogger({
          transports: [
            new winston.transports.Console(),
            new winston.transports.File({ filename: 'combined.log' }),
          ],
        });
      },
    },
  ],
  exports: [LogService]
})
export class LogModule {}